export default {
  getRegionsByApi (params) {
    return window._xvueAxios({
      method: 'post',
      url: `/dcp/data/data/v2/getByApiCode`, // 获取单个区域数据
      data: params
    })
  },
  getCurrentRegionPrtChdRegs (areaCode) {
    return new Promise(resolve => {
      window._xvueAxios({
        method: 'post',
        url: '/dcp/data/data/v1/web/area/queryGridTree',
        data: [areaCode]
      })
        .then(res => {
          if (res && res.data) {
            const _data = res.data.data
            resolve(_data)
          } else {
            resolve([])
          }
        })
        .catch(err => {
          console.error(err)
          resolve([])
        })
    })
  },
  getTopRegion (tenantId) {
    return window._xvueAxios({
      method: 'get',
      url: `/iam/uc/v1/areas?tenantId=${tenantId}&parentCode=-1`
    })
  }
}
